package demo4;

/**
 * 两两交换链表中的结点
 * https://leetcode.cn/problems/swap-nodes-in-pairs/description/
 */
class Solution {
    public ListNode swapPairs(ListNode head) {
        // 出口
        if(head == null || head.next == null) return head;

        ListNode tmp = swapPairs(head.next.next);
        ListNode ret = head.next;
        head.next.next = head;
        head.next = tmp;
        return ret;
    }
}